//
//  MineShareDanController.swift
//  HappyEat
//
//  Created by ctx2016 on 17/1/16.
//  Copyright © 2017年 陌路是我. All rights reserved.
//

import UIKit

class MineShareDanController: UIViewController ,UITableViewDelegate,UITableViewDataSource{
    
    var tableView:UITableView = UITableView.init()
    
    let CellId:String = "CELLID"
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.setUI()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.setNav()
    }
}
extension MineShareDanController{
    func setNav(){
        self.navigationItem.title = "幸运记录"
        self.navigationController?.navigationBar.barTintColor = .red
        self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(title: "", imagStr: "ic_back", fontSize: 14, target: self, action: #selector(leftButtonAction))
    }
    func leftButtonAction(){
        self.navigationController!.popViewController(animated: true)
    }
    func setUI(){
        self.view.addSubview(self.tableView)
        self.tableView.snp.makeConstraints { (make) in
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.top.equalTo(0)
            make.bottom.equalTo(0)
        }
        
        self.tableView.delegate = self
        self.tableView.dataSource = self
        self.tableView.register(ShareDanCell.self , forCellReuseIdentifier: CellId)
        tableView.separatorStyle = .none
    }
    ///MARk:tableviewDelegate
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    @objc(numberOfSectionsInTableView:) func numberOfSections(in tableView: UITableView) -> Int {
        return 10
    }
    @objc(tableView:cellForRowAtIndexPath:) func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = ShareDanCell.init(style: .default, reuseIdentifier: CellId)
        cell.typeShare = .mineShareType
        cell.selectionStyle = .none
        cell.qhLabel.text = "期号:312145"
        cell.userNameLabel.text = "满足我的小心愿"
        cell.dateLabel.text = "2016-12-24 08:00"
        cell.infoLabel.text = "味道真心不错，希望大家都有好运气奥~味道真心不错，希望大家都有好运气奥~味道真心不错，希望大家都有好运气奥~"
        cell.dataDic = ["":""]
        return cell
    }
    @objc(tableView:heightForRowAtIndexPath:) func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        let height:CGFloat = UILabel.init().jqGetHeightWithstr("味道真心不错，希望大家都有好运气奥~味道真心不错，希望大家都有好运气奥~味道真心不错，希望大家都有好运气奥~", withfontSize: 14, withLineSpace: 0, withmaxWidth: k_Wide - 32)
        //        if height > 28.0{
        //            height = 28.0
        //        }
        return 45 + 24 + 8 + 12 + 75 + height
    }
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.001
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        switch section {
        case 0:
            return 0.001
        default:
            return 12
        }
    }
}
